class AsyncParallelHook {
    constructor() {
        this.tasks = [];
    }
    tapAsync(name, task) {
        this.tasks.push(task);
    }
    callAsync(...args) {
        const endCb = args.pop();
        let index = 0;
        const done = () => {
            index++;
            if (index === this.tasks.length) {
                endCb();
            }
        }
        this.tasks.forEach(task => {
            task(...args, done)
        });
    }
    tapPromise(name, task) {
        this.tasks.push(task);
    }
    promise(...args) {
        let promiseTasks = this.tasks.map(task => task(...args));
        return Promise.all(promiseTasks);
    }
}
module.exports = AsyncParallelHook;